package com.gc.business.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gc.common.utils.StringUtils;
import org.springframework.stereotype.Service;
import com.gc.business.mapper.AttachmentMapper;
import com.gc.business.domain.Attachment;
import com.gc.business.service.IAttachmentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;

/**
 * 附件 服务层实现
 * 
 * @author liujinteng
 * @date 2020-11-06
 */
@Slf4j
@Service
public class AttachmentServiceImpl extends ServiceImpl<AttachmentMapper, Attachment> implements IAttachmentService {

    @Override
    public List<Attachment> list(Attachment attachment){
        LambdaQueryWrapper<Attachment> wrapper = new LambdaQueryWrapper<>();
        if(attachment != null){
            if(StringUtils.isNotEmpty(attachment.getAttachId())){
                wrapper.eq(Attachment::getAttachId, attachment.getAttachId());
            }
            if(StringUtils.isNotEmpty(attachment.getAttachTitle())){
                wrapper.like(Attachment::getAttachTitle, attachment.getAttachTitle());
            }
            if(StringUtils.isNotEmpty(attachment.getAttachUrl())){
                wrapper.eq(Attachment::getAttachUrl, attachment.getAttachUrl());
            }
            if(StringUtils.isNotEmpty(attachment.getAttachSize())){
                wrapper.eq(Attachment::getAttachSize, attachment.getAttachSize());
            }
            if(StringUtils.isNotEmpty(attachment.getBusinessId())){
                wrapper.eq(Attachment::getBusinessId, attachment.getBusinessId());
            }
            if(StringUtils.isNotEmpty(attachment.getBusinessType())){
                wrapper.eq(Attachment::getBusinessType, attachment.getBusinessType());
            }
            if(StringUtils.isNotEmpty(attachment.getIsImg())){
                wrapper.eq(Attachment::getIsImg, attachment.getIsImg());
            }
            if(StringUtils.isNotEmpty(attachment.getIconUrl())){
                wrapper.eq(Attachment::getIconUrl, attachment.getIconUrl());
            }
            if(StringUtils.isNotEmpty(attachment.getUserId())){
                wrapper.eq(Attachment::getUserId, attachment.getUserId());
            }
            if(StringUtils.isNotEmpty(attachment.getCreateBy())){
                wrapper.eq(Attachment::getCreateBy, attachment.getCreateBy());
            }
            if(StringUtils.isNotEmpty(attachment.getCreateTime())){
                wrapper.eq(Attachment::getCreateTime, attachment.getCreateTime());
            }
        }
        return baseMapper.selectList(wrapper);
    }
}
